//导入vue
import Vue from 'vue';
import VueRouter from 'vue-router';
import axios from 'axios'
import VueAxios from 'vue-axios'

//导入组件
import Login from "../views/Login";
import Frame from "../views/Frame";
import Main from "../views/Main";
import Scheduling from "../views/Scheduling";
import Center from "../views/Center";
import Administration from "../views/Administration";
import NotFound from "../views/NotFound";

//使用
Vue.use(VueRouter);
Vue.use(VueAxios, axios);

//NavigationDuplicated: Avoided redundant navigation to current location: “/mine“解决方案
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};

export default new VueRouter({
  mode: 'history',
  routes:[
    {
      //登录页
      path:'/Login',
      component: Login,
    },
    {
       //框架Frame
       path:'/frame/:username',
       component: Frame,
        props:true,
      //子模块
      children:[
        {
          //主页Main
          path:'/Main',
          component: Main,
        },
        {
          //排班Scheduling
          path:'/Scheduling',
          component: Scheduling,
        },
        {
          //护士和助手管理 Administration
          path:'/Administration',
          component: Administration,
        },
        {
          //个人信息管理中心Main
          path:'/Center',
          component: Center,
        },
      ],
      /*meta: {
        requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      },*/
    },

    {
      //若找不到路径，则会跳转到这个NotFound.vue界面
      path:'*',
      component: NotFound,
    },
]
});


